import http from '@/api'
import { ADMIN_MODULE } from '@/api/helper/prefix'
import type { IPage } from '@/api/types';
import type { DetailModeSideBarQuery, DetailModeSideBarRow, DetailModeSideBarForm } from '@/api/types/detailmodel/detailModeSideBar'
import type { UploadRawFile } from "element-plus/es/components/upload/src/upload";
import type { AxiosRequestConfig } from 'axios';

/**
* 查询列表
* @param params
* @returns {*}
*/
export const getDetailModeSideBarListApi = (params: DetailModeSideBarQuery) => {
  return http.get<IPage<DetailModeSideBarRow>>(ADMIN_MODULE + `/detail-mode-side-bar`, params)
}

/**
* 获取树
*/
export const getDetailModeSideBarTreeApi = (params: {masterId: number}) => {
  return http.get<IPage<DetailModeSideBarRow>>(ADMIN_MODULE + `/detail-mode-side-bar/orderTrees`, params)
}

/**
* 添加
* @param params
* @returns {*}
*/
export const createDetailModeSideBarApi = (params: DetailModeSideBarForm) => {
  return http.post(ADMIN_MODULE + `/detail-mode-side-bar`, params)
}

/**
* 批量保存
* @param params
* @returns {*}
*/
export const batchUpdateDetailModeSideBarApi = (params: []) => {
  return http.post(ADMIN_MODULE + `/detail-mode-side-bar/batchUpdate`, params)
}

/**
* 修改
* @param params
* @returns {*}
*/
export const updateDetailModeSideBarApi = (params: DetailModeSideBarForm) => {
  return http.put(ADMIN_MODULE + `/detail-mode-side-bar`, params)
}

/**
* 删除
* @param params
* @returns {*}
*/
export const removeDetailModeSideBarApi = (params: { ids: (string | number)[] }) => {
 return http.delete(ADMIN_MODULE + `/detail-mode-side-bar`, params)
}

/**
* 获取详情
* @param params
* @returns {*}
*/
export const getDetailModeSideBarDetailApi = (params: { id: number }) => {
  const { id } = params
  return http.get<DetailModeSideBarRow>(ADMIN_MODULE + `/detail-mode-side-bar/${id}`)
}

/**
* 导入excel
* @param params
*/
export const importDetailModeSideBarExcelApi = (params : UploadRawFile, config?: AxiosRequestConfig<any> | undefined) => {
  return http.upload(ADMIN_MODULE + `/detail-mode-side-bar/import`, params, config)
}

/**
* 导出excel
* @param params
* @returns {*}
*/
export const exportDetailModeSideBarExcelApi  = (params: DetailModeSideBarQuery) => {
  return http.download(ADMIN_MODULE + `/detail-mode-side-bar/export`, params)
}